package com.snatchnd.manager.util;

import java.util.regex.Pattern;




public class GameUtil {
	
	public static void main(String[] args) throws Exception {
		long ij = System.currentTimeMillis();
		System.out.println(isNumeric("20"));
		for(int i= 0;i<99999;i++){
			isNumeric("1a2");
		}
		System.out.println("打印："+(System.currentTimeMillis()-ij));
	}
	
	
	public static boolean isNumeric(String str){ 
		Pattern pattern = Pattern.compile("[0-9]*"); 
	    return pattern.matcher(str).matches();    
	 } 
	/**
	 * 得到盘口
	 * @param odd
	 * @return
	 */
	public static int getOdd(String odd) throws Exception{
		if(odd==null)return 0;
		
		int odds = 1;		
		if(odd.indexOf("-")!=-1){
			odds = -1;
			odd=odd.substring(1, odd.length());
		}
		if(odd.indexOf("/")==-1){
			Double n = new Double(odd);
			odds *= n * 4;
		}else{
			String[] oddstr = odd.split("/");
			if(oddstr.length==2){
				Double n1 = new Double(oddstr[0]);
				Double n2 = new Double(oddstr[1]);
				odds *= (n1+n2)*2;
			}
		}
		return odds;
	}
}
